import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:fwanandroid/model/api/DioClient.dart';
import 'package:fwanandroid/provider/UserState.dart';
import 'package:fwanandroid/ui/login/LoginPage.dart';
import 'package:fwanandroid/ui/main/MainPage.dart';
import 'package:fwanandroid/ui/search/SearchResultPage.dart';
import 'package:fwanandroid/ui/web/WebPage.dart';
import 'package:provider/provider.dart';
import 'package:toast/toast.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  DioClient().init();
  runApp(ChangeNotifierProvider(
    create: (context) => UserState(),
    child: const MyApp(),
  ));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      // 路由相关
      initialRoute: '/',
      navigatorKey: GlobalKey<NavigatorState>(),
      routes: {
        '/': (context) => MainPage(),
        '/login': (context) => LoginPage(),
        '/searchResult': (context) => SearchResultPage(),
        '/web': (context) => WebPage()
      },
      builder: EasyLoading.init(),
    );
  }
}
